package com.example.customer.controller;

import com.example.customer.dto.PageBean;
import com.example.customer.service.pageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

@CrossOrigin(methods = {RequestMethod.POST,RequestMethod.GET})
@Controller
@RequestMapping("/policyholders")
public class pageController {
    @Autowired
    private pageService pageService;

    //投保人分页查询
    @RequestMapping("/select.do")
    public @ResponseBody PageBean list(PageBean pageBean, HttpServletResponse response, HttpSession session)throws Exception{
        //response.setHeader("Access-Control-Allow-Origin", "*");

        System.out.println("login:sessionid:"+session.getId());
        System.out.println("开始："+pageBean.getCurrentPage()+"结束"+pageBean.getPageSize());
        return this.pageService.getAllPolicyholdersInfo(pageBean.getCurrentPage(), pageBean.getPageSize(),pageBean.getName(),pageBean.getCredentials_number());

    }


    //被投保人分页查询
    @RequestMapping("/get.do")
    public @ResponseBody PageBean getRecognizeeinfo(PageBean pageBean, HttpServletResponse response, HttpSession session)throws Exception{
        //response.setHeader("Access-Control-Allow-Origin", "*");

        System.out.println("login:sessionid:"+session.getId());
        System.out.println("开始："+pageBean.getCurrentPage()+"结束"+pageBean.getPageSize());
        return this.pageService.getAllRecognizeeInfo(pageBean.getCurrentPage(), pageBean.getPageSize(),pageBean.getName(),pageBean.getCredentials_number());

    }

}
